<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Update information stored in an ID3 tag</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.id3-remove-tag.html">id3_remove_tag</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="book.ktaglib.html">KTaglib</a></div>
 <div class="up"><a href="ref.id3.html">ID3 函数</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="function.id3-set-tag" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">id3_set_tag</h1>
  <p class="verinfo">(PECL id3 &gt;= 0.1)</p><p class="refpurpose"><span class="refname">id3_set_tag</span> &mdash; <span class="dc-title">Update information stored in an ID3 tag</span></p>

 </div>
 <div class="refsect1 description" id="refsect1-function.id3-set-tag-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="type">bool</span> <span class="methodname"><strong>id3_set_tag</strong></span>
    ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$filename</code></span>
   , <span class="methodparam"><span class="type">array</span> <code class="parameter">$tag</code></span>
   [, <span class="methodparam"><span class="type">int</span> <code class="parameter">$version</code><span class="initializer"> = ID3_V1_0</span></span>
  ] )</div>

  <p class="para rdfs-comment">
   <span class="function"><strong>id3_set_tag()</strong></span> is used to change the information stored
   of an ID3 tag. If no tag has been present, it will be added to the file.
  </p>
 </div>

 <div class="refsect1 parameters" id="refsect1-function.id3-set-tag-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>

    
     <dt>
<em><code class="parameter">filename</code></em></dt>

     <dd>

      <p class="para">
       The path to the MP3 file
      </p>
      <p class="para">
       Instead of a filename you may also pass a valid stream resource
      </p>
     </dd>

    
    
     <dt>
<em><code class="parameter">tag</code></em></dt>

     <dd>

      <p class="para">
       An associative array of tag keys and values
      </p>
      <p class="para">
       The following keys may be used in the associative array:
      </p>
      <p class="para">
       <table class="doctable table">
        <caption><strong>Keys in the associative array</strong></caption>
        
         <thead>
          <tr>
           <th>key</th>
           <th>possible value</th>
           <th>available in version</th>
          </tr>

         </thead>

         <tbody class="tbody">
          <tr>
           <td>title</td>
           <td>string with maximum of 30 characters</td>
           <td>v1.0, v1.1</td>
          </tr>

          <tr>
           <td>artist</td>
           <td>string with maximum of 30 characters</td>
           <td>v1.0, v1.1</td>
          </tr>

          <tr>
           <td>album</td>
           <td>string with maximum of 30 characters</td>
           <td>v1.0, v1.1</td>
          </tr>

          <tr>
           <td>year</td>
           <td>4 digits</td>
           <td>v1.0, v1.1</td>
          </tr>

          <tr>
           <td>genre</td>
           <td>integer value between 0 and 147</td>
           <td>v1.0, v1.1</td>
          </tr>

          <tr>
           <td>comment</td>
           <td>string with maximum of 30 characters (28 in v1.1)</td>
           <td>v1.0, v1.1</td>
          </tr>

          <tr>
           <td>track</td>
           <td>integer between 0 and 255</td>
           <td>v1.1</td>
          </tr>

         </tbody>
        
       </table>

      </p>
     </dd>

    
    
     <dt>
<em><code class="parameter">version</code></em></dt>

     <dd>

      <p class="para">
       Allows you to specify the version of the tag as MP3 files may contain
       both, version 1.x and version 2.x tags
      </p>
     </dd>

    
   </dl>

  </p>
 </div>

 <div class="refsect1 returnvalues" id="refsect1-function.id3-set-tag-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   成功时返回 <strong><code>TRUE</code></strong>， 或者在失败时返回 <strong><code>FALSE</code></strong>。
  </p>
 </div>

 <div class="refsect1 examples" id="refsect1-function.id3-set-tag-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-573">
    <p><strong>Example #1 <span class="function"><strong>id3_set_tag()</strong></span> example</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$data&nbsp;</span><span style="color: #007700">=&nbsp;array(<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">"title"&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">"Re:Start"</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">"artist"&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">"Re:\Legion"</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">"comment"&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">"A&nbsp;nice&nbsp;track"<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$result&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">id3_set_tag</span><span style="color: #007700">(&nbsp;</span><span style="color: #DD0000">"path/to/example.mp3"</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$data</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">ID3_V1_0&nbsp;</span><span style="color: #007700">);<br />if&nbsp;(</span><span style="color: #0000BB">$result&nbsp;</span><span style="color: #007700">===&nbsp;</span><span style="color: #0000BB">true</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"Tag&nbsp;successfully&nbsp;updated\n"</span><span style="color: #007700">;<br />}<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

    <div class="example-contents"><p>
     If the file is writable, this will output:
    </p></div>
    <div class="example-contents screen">
<div class="cdata"><pre>
Tag successfully updated
</pre></div>
    </div>
   </div>
  </p>
 </div>

 <div class="refsect1 notes" id="refsect1-function.id3-set-tag-notes">
  <h3 class="title">注释</h3>
  <blockquote class="note"><p><strong class="note">Note</strong>: 
   <span class="simpara">
    Currently <span class="function"><strong>id3_set_tag()</strong></span> only supports version 1.0
    and 1.1. 
   </span>
  </p></blockquote>
 </div>

 <div class="refsect1 seealso" id="refsect1-function.id3-set-tag-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="function"><a href="function.id3-remove-tag.html" class="function" rel="rdfs-seeAlso">id3_remove_tag()</a> - Remove an existing ID3 tag</span></li>
    <li class="member"><span class="function"><a href="function.id3-get-tag.html" class="function" rel="rdfs-seeAlso">id3_get_tag()</a> - Get all information stored in an ID3 tag</span></li>
    <li class="member"><span class="function"><a href="function.id3-get-version.html" class="function" rel="rdfs-seeAlso">id3_get_version()</a> - Get version of an ID3 tag</span></li>
   </ul>
  </p>
 </div>

</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.id3-remove-tag.html">id3_remove_tag</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="book.ktaglib.html">KTaglib</a></div>
 <div class="up"><a href="ref.id3.html">ID3 函数</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>
